﻿using Microsoft.AspNetCore.Razor.TagHelpers;

namespace Longbow.Web.Mvc.TagHelpers
{
    /// <summary>
    /// 条件标签类
    /// </summary>
    [HtmlTargetElement(Attributes = "asp-condition", TagStructure = TagStructure.NormalOrSelfClosing)]
    public class ConditionTagHelper : TagHelper
    {
        /// <summary>
        /// 获得/设置 标签生成条件
        /// </summary>
        [HtmlAttributeName("asp-condition")]
        public bool Condition { get; set; }

        /// <summary>
        /// 标签处理方法
        /// </summary>
        /// <param name="context"></param>
        /// <param name="output"></param>
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            if (!Condition) output.SuppressOutput();
        }
    }
}
